package com.kyh.util.qiniucloud;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class QiniucloudProperties {
	
	private static String AccessKey; // 七牛AK
	private static String SecretKey; // 七牛SK
	private static String qiniuBucketName; // 七牛bucketname
	private static String qiniuDomainhttps; // 含https的域名test
	private static String qiniuDomainAll; // 含http的域名test
	
	private static QiniucloudProperties instance;
	private QiniucloudProperties(){}
	public static QiniucloudProperties getInstance() {
		if (instance == null) {
			instance = new QiniucloudProperties();
			Properties properties = new Properties();
			InputStream in = null;
			try {
				in = QiniuCloudUtil.class.getResourceAsStream("/qiniuyuncloud.properties");
				properties.load(in);
				in.close();
				
				AccessKey = properties.getProperty("accesskey");
				SecretKey = properties.getProperty("secretkey");
				qiniuBucketName = properties.getProperty("bucketname");
				qiniuDomainhttps = properties.getProperty("domainhttps");
				qiniuDomainAll = properties.getProperty("domain");
			} catch (IOException e) {
				e.printStackTrace();
			} finally {
				if (in != null) {
					try {
						in.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
		}
		return instance;
	}
	
	public String getAccessKey() {
		return AccessKey;
	}
	public void setAccessKey(String accessKey) {
		AccessKey = accessKey;
	}
	public String getSecretKey() {
		return SecretKey;
	}
	public void setSecretKey(String secretKey) {
		SecretKey = secretKey;
	}
	public String getQiniuBucketName() {
		return qiniuBucketName;
	}
	public void setQiniuBucketName(String qiniuBucketName) {
		QiniucloudProperties.qiniuBucketName = qiniuBucketName;
	}
	public String getQiniuDomainhttps() {
		return qiniuDomainhttps;
	}
	public void setQiniuDomainhttps(String qiniuDomainhttps) {
		QiniucloudProperties.qiniuDomainhttps = qiniuDomainhttps;
	}
	public String getQiniuDomainAll() {
		return qiniuDomainAll;
	}
	public void setQiniuDomainAll(String qiniuDomainAll) {
		QiniucloudProperties.qiniuDomainAll = qiniuDomainAll;
	}
}
